package com.assetmanage.service.impl;

import com.assetmanage.dao.UserDao;
import com.assetmanage.dao.impl.UserDaoImpl;
import com.assetmanage.model.User;
import com.assetmanage.service.UserService;

import java.util.List;

public class UserServiceImpl implements UserService {
    private UserDao userDao = new UserDaoImpl();

    @Override
    public User login(String username, String password) {
        return userDao.login(username, password);
    }

    @Override
    public List<User> getAllUsers() {
        return userDao.getAllUsers();
    }

    @Override
    public List<User> getUsersByDepartment(String depId) {
        return userDao.getUsersByDepartment(depId);
    }

    @Override
    public boolean addUser(User user) {
        return userDao.addUser(user);
    }

    @Override
    public boolean updateUser(User user) {
        return userDao.updateUser(user);
    }

    @Override
    public boolean deleteUser(int uId) {
        return userDao.deleteUser(uId);
    }

    @Override
    public User getUserById(int uId) {
        return userDao.getUserById(uId);
    }

    @Override
    public boolean isAdmin(int uId) {
        User user = getUserById(uId);
        return user != null && "yes".equals(user.getAdmin());
    }
} 